//
//  BaseViewController.m
//  FNer
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 刘志强. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:231 / 255.0 green:231 / 255.0 blue:231 / 255.0 alpha:1];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:50 / 255.0 green:50 / 255.0 blue:50 / 255.0 alpha:1.0];
    
    NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"night"];
    if ([str isEqualToString:@"yes"]) {
#warning 改的颜色
        self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"changeColor" object:nil];
}

-(void)changeColor:(NSNotification *)notification
{
#warning 改的颜色
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    
    NSString *str = [notification object];
    if ([str isEqualToString:@"no"]) {
#warning 原有颜色
        self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:50 / 255.0 green:50 / 255.0 blue:50 / 255.0 alpha:1.0];
    }
    //保存当前状态值
    [[NSUserDefaults standardUserDefaults] setObject:str forKey:@"night"];
}
    


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
